/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Paul
 */
@Entity
@Table(name = "candidat")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Candidat.findAll", query = "SELECT c FROM Candidat c"),
    @NamedQuery(name = "Candidat.findByIdCandidat", query = "SELECT c FROM Candidat c WHERE c.idCandidat = :idCandidat"),
    @NamedQuery(name = "Candidat.findByDiplomes", query = "SELECT c FROM Candidat c WHERE c.diplomes = :diplomes"),
    @NamedQuery(name = "Candidat.findByCompetences", query = "SELECT c FROM Candidat c WHERE c.competences = :competences"),
    @NamedQuery(name = "Candidat.findBySituationPro", query = "SELECT c FROM Candidat c WHERE c.situationPro = :situationPro"),
    @NamedQuery(name = "Candidat.findByMotivation", query = "SELECT c FROM Candidat c WHERE c.motivation = :motivation")})
public class Candidat implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCandidat")
    private Integer idCandidat;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "diplomes")
    private String diplomes;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "competences")
    private String competences;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "situationPro")
    private String situationPro;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "motivation")
    private String motivation;
    @JoinTable(name = "formation_candidat_asso", joinColumns = {
        @JoinColumn(name = "idCandidat", referencedColumnName = "idCandidat")}, inverseJoinColumns = {
        @JoinColumn(name = "idFormation", referencedColumnName = "idFormation")})
    @ManyToMany
    private Collection<Formation> formationCollection;
    @JoinColumn(name = "idUtilisateur", referencedColumnName = "idUtilisateur")
    @ManyToOne(optional = false)
    private Utilisateur idUtilisateur;

    public Candidat() {
    }

    public Candidat(Integer idCandidat) {
        this.idCandidat = idCandidat;
    }

    public Candidat(Integer idCandidat, String diplomes, String competences, String situationPro, String motivation) {
        this.idCandidat = idCandidat;
        this.diplomes = diplomes;
        this.competences = competences;
        this.situationPro = situationPro;
        this.motivation = motivation;
    }

    public Integer getIdCandidat() {
        return idCandidat;
    }

    public void setIdCandidat(Integer idCandidat) {
        this.idCandidat = idCandidat;
    }

    public String getDiplomes() {
        return diplomes;
    }

    public void setDiplomes(String diplomes) {
        this.diplomes = diplomes;
    }

    public String getCompetences() {
        return competences;
    }

    public void setCompetences(String competences) {
        this.competences = competences;
    }

    public String getSituationPro() {
        return situationPro;
    }

    public void setSituationPro(String situationPro) {
        this.situationPro = situationPro;
    }

    public String getMotivation() {
        return motivation;
    }

    public void setMotivation(String motivation) {
        this.motivation = motivation;
    }

    @XmlTransient
    public Collection<Formation> getFormationCollection() {
        return formationCollection;
    }

    public void setFormationCollection(Collection<Formation> formationCollection) {
        this.formationCollection = formationCollection;
    }

    public Utilisateur getIdUtilisateur() {
        return idUtilisateur;
    }

    public void setIdUtilisateur(Utilisateur idUtilisateur) {
        this.idUtilisateur = idUtilisateur;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCandidat != null ? idCandidat.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Candidat)) {
            return false;
        }
        Candidat other = (Candidat) object;
        if ((this.idCandidat == null && other.idCandidat != null) || (this.idCandidat != null && !this.idCandidat.equals(other.idCandidat))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Candidat[ idCandidat=" + idCandidat + " ]";
    }
    
}
